package com.yisa.person.config;

import net.anumbrella.seaweedfs.core.FileSource;
import net.anumbrella.seaweedfs.core.FileTemplate;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;

@Configuration
public class SeaweedFSConfig {

    @Value("${seaweedfs.host}")
    private String host;
    @Value("${seaweedfs.port}")
    private int port;

    @Bean
    public FileTemplate fileTemplate() {

        FileSource fileSource = new FileSource();
        // SeaweedFS master服务ip地址
        fileSource.setHost(host);
        // SeaweedFS master服务端口
        fileSource.setPort(port);
        try {
            // 启动服务
            fileSource.startup();
        } catch (Exception e) {
            e.printStackTrace();
        }
        return new FileTemplate(fileSource.getConnection());
    }
}